package me.zhengjie.dailyPoem.rest;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.AnonymousAccess;
import me.zhengjie.annotation.Log;
import me.zhengjie.dailyPoem.domain.vo.QueryCriteria;
import me.zhengjie.dailyPoem.mapper.PoemRecommendMapper;
import me.zhengjie.dailyPoem.service.PoemRecommendService;
import me.zhengjie.poemPoet.domain.PoemPoet;
import me.zhengjie.poemmanager.domain.Query;
import me.zhengjie.poemmanager.domain.UserInfoCount;
import me.zhengjie.utils.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/poem")
@RequiredArgsConstructor
public class PoemRecommendController {
    @Autowired        
    private PoemRecommendMapper poemRecommendMapper;
    @Autowired
    private PoemRecommendService  poemRecommendService;
    @GetMapping(value = "/poemrecommend")
    @AnonymousAccess
    public PoemPoet poemRecommend() {
        return poemRecommendMapper.poemRecommend();
    }

    @GetMapping(value = "/dailypoem")
    @AnonymousAccess
    public PoemPoet getDailyPoem() {return poemRecommendService.getDailyPoem();}

    @GetMapping(value = "/relatedpoem")
    @AnonymousAccess
    public List<PoemPoet> getRelatedPost() {
        return poemRecommendMapper.getRelatedPost();
    }


    @GetMapping("/getUserCountInfo")
    @Log("获取用户相关信息")
    @ApiOperation("获取用户相关信息")
    @AnonymousAccess
    public UserInfoCount getRealtedInfo(@RequestParam String userName){
        return poemRecommendMapper.getRealtedInfo(userName);
    }

    @GetMapping("/query")
    @Log("根据关键字查询")
    @ApiOperation("根据关键字查询")
    @AnonymousAccess
    public List<Query> queryInfo(@RequestParam String keyWord){
        return poemRecommendMapper.queryInfo(keyWord);
    }


}
